<template>
  <div id="app">
    <button @click="$store.commit('a/syncChange', { step: 10 })">
      a/syncChange - Age: {{ $store.state.age }}
    </button>
    <button @click="$store.commit('c/syncChange', { step: 10 })">
      c/syncChange - Age: {{ $store.state.age }}
    </button>
    <p>全局Age: {{ age }}</p>
    <p>aAge: {{ $store.state.a.age }}</p>
    <p>bAge: {{ $store.state.b.age }}</p>
    <p>cAge: {{ $store.state.b.c.age }}</p>
    <p>dAge: {{ $store.state.d.age }}</p>
    <!-- <button @click="$store.commit('syncChange', { step: 10 })">
      Age: {{ $store.state.age }}
    </button> -->
    <button @click="syncChange({ step: 10 })">
      Age: {{ $store.state.age }}
    </button>
    <button @click="$store.dispatch('asyncChange', { step: 2 })">
      Age: {{ $store.state.age }}
    </button>
    <button>myAge: {{ myAge }}</button>
  </div>
</template>

<script>
import { mapGetters, mapMutations, mapState } from './vuex'

export default {
  name: 'App',
  computed: {
    ...mapGetters(['myAge']),
    ...mapState(['age'])
  },
  methods: {
    ...mapMutations({ syncChange: 'syncChange' })
  }
}
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
